package com.xiaotu.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@PropertySource("classpath:/properties/image.properties")
public class ConfigurerAdapter implements WebMvcConfigurer {
    @Value("${file.path}")
    private String filePath;
    @Value("${file.url}")
    private String fileUrl;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //释放静态资源
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        //允许访问系统资源
        registry.addResourceHandler(fileUrl).addResourceLocations("file:"+filePath);
    }
}
